package com.niit.mobileDevide.batterydrain;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class BatteryDrainReducer extends Reducer<Text, BatteryDrainBean, Text, Text> {

    @Override
    protected void reduce(Text key, Iterable<BatteryDrainBean> values, Context context) throws IOException, InterruptedException {
        int totalCount = 0;

        // 统计每个操作系统的总记录数
        for (BatteryDrainBean val : values) {
            totalCount += val.getCount();
        }

        // 输出结果
        context.write(key, new Text("Count: " + totalCount));
    }
}